<?php
class cordonController extends baseController
{
	public function show(){
		$count = CordonHelper::count();
		$pager = PagerHelper::split($count);
		$list  = CordonHelper::getList(null, $pager['r_offset'], $pager['p_size']);
		$this->assign('list', $list);
		$this->display();
	}
	
	public function set(){
		if(is_post())
		{
			foreach($_POST['hem'] as $sid=>$v)
			{
				CordonHelper::set($sid, $v);
			}
			Show::note("设置成功");
		}
		else
		{
			$where = array();
			if($key=fetch_a_string('key')){
				$fields = array('sno','name','specific','unit','brand','remark');
				$GLOBALS['S_KEY'] = $key;
				$func = function($v){ return "`{$v}` LIKE '%{$GLOBALS['S_KEY']}%'"; };
				$where[] = ('('. join(' OR ', array_map($func, $fields)). ')');
			}
			$where = join(' AND ', $where);
			
			$list  = WareHelper::getList($where);
			$this->assign('list', $list);
			$this->display();
		}
	}
		
	public function less(){
		$list = CordonHelper::getLessList();
		$this->assign('list', $list);
		$this->display();
	}
	
}
?>
